<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import = "java.sql.*, java.util.*" %>
<%@ include file="db.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String num=request.getParameter("num");
String pass=request.getParameter("pass");

PreparedStatement pstmt = null;
ResultSet rs = null;

String strSQL = "SELECT pass FROM s_store WHERE num = ?";
pstmt = conn.prepareStatement(strSQL);
pstmt.setInt(1, Integer.parseInt(num));
rs = pstmt.executeQuery();
rs.next();

String goodpass = rs.getString("pass").trim();
if(pass.equals(goodpass))
{
	strSQL = "DELETE From s_store WHERE num=?";
	pstmt=conn.prepareStatement(strSQL);
	pstmt.setInt(1, Integer.parseInt(num));
	pstmt.executeUpdate();
	
	strSQL = "UPDATE s_store SET num = num -1 WHERE num > ?";
	pstmt = conn.prepareStatement(strSQL);
	pstmt.setInt(1, Integer.parseInt(num));
	pstmt.executeUpdate();
	
	response.sendRedirect("del_pass.jsp?num" + num);
}

rs.close();
pstmt.close();
conn.close();
%>